#include <stdio.h>

int main( )
{
    int a, b, k;
    while ( scanf("%d%d%d", &a, &b, &k) != EOF )
    {
        if ( a == 0 && b == 0 )
            break;
        int sum = 1;
        while ( k-- )
        {
            sum *= 10;
        }
        if ( a % sum != b % sum )
            printf("%d\n", a + b);
        else
            printf("-1\n");
    }
    return 0;
}
